package presentation.teacherui;

import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import presentation.userui.UserUI;

public class TeacherUI {

	private JFrame frame;
	private MyPanel panel;

	/**
	 * Launch the application.
	 */

	/**
	 * Create the application.
	 */
	public TeacherUI() {
		initialize();
	}
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 600, 460);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);

		JMenuBar menuBar = new JMenuBar();
		menuBar.setBounds(0, 0, 584, 21);
		frame.getContentPane().add(menuBar);
		
		JMenu menu = new JMenu("\u9996\u9875");
		menuBar.add(menu);
		
		JMenuItem menuItem = new JMenuItem("\u9996\u9875");
		menuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				panel.removeAll();
	     	 	panel.add(new FirstPanel().panel);
	     	 	panel.repaint();
				frame.setVisible(true);
			}
		});
		menu.add(menuItem);
		
		JMenu menu_1 = new JMenu("\u8BFE\u7A0B\u4FE1\u606F");
		menuBar.add(menu_1);
		
		JMenuItem menuItem_1 = new JMenuItem("\u8F93\u5165\u8BFE\u7A0B\u5927\u7EB2");
		menuItem_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				panel.removeAll();
				panel.add(new FillCourseInfoPanel().panel);
				panel.repaint();
				frame.setVisible(true);	
			}
		});
		menu_1.add(menuItem_1);
		
		JMenu menu_2 = new JMenu("\u5B66\u751F");
		menuBar.add(menu_2);
		
		JMenuItem menuItem_2 = new JMenuItem("\u67E5\u770B\u5B66\u751F\u5217\u8868");
		menuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				panel.removeAll();
				panel.add(new showStudentListPanel().panel);
				panel.repaint();
				frame.setVisible(true);
			}
		});
		menu_2.add(menuItem_2);
		
		JMenuItem menuItem_3 = new JMenuItem("\u767B\u8BB0\u6210\u7EE9");
		menuItem_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				panel.removeAll();
				panel.add(new RecordScorePanel().panel);
				panel.repaint();
				frame.setVisible(true);
			}
		});
		menu_2.add(menuItem_3);
		
		JMenu menu_3 = new JMenu("\u9000\u51FA\u767B\u5F55");
		menuBar.add(menu_3);
		
		JMenuItem menuItem_4 = new JMenuItem("\u9000\u51FA\u767B\u5F55");
		menuItem_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.dispose();
				new UserUI();
			}
		});
		menu_3.add(menuItem_4);
		
		
		panel=new MyPanel();
		panel.setLayout(null);
		panel.setBounds(0,20,584,402);
		
		panel.removeAll();
 	 	panel.add(new FirstPanel().panel);
		frame.getContentPane().add(panel);

		frame.setVisible(true);	
	}
	
	   public class MyPanel extends JPanel{
	    	  public void paintComponent(Graphics g){
	    		  Image image=new ImageIcon("img/teacher.jpg").getImage();
	    		  g.drawImage(image,0,0,this);
	    	  }
	      }
}
